import { ApiCall } from "tsrpc";
import { WorldServerConn } from "../WorldServer";
import { SubWorldBilliards } from "../models/SubWorldBilliards";
import { ReqJoinGame, ResJoinGame } from "../../shared/protocols/worldServer/PtlJoinGame";

export async function ApiJoinGame(call: ApiCall<ReqJoinGame, ResJoinGame>) {
    // TODO
    const conn = call.conn as WorldServerConn;

    let current = conn.currentSubWorld as SubWorldBilliards;
    if (!current) {
        return call.error('NO_TABLE');
    }

    return current.onRPC_JoinGame(call);
}